// The method of defining a class.

#include <iostream>
#include <cstring>
using namespace std;


class Human {
	public:
		Human( int age=0, const char* name="wuming" );
		void getinfo( );	// Declaration
	private:
		int age;
		char name[16];
};

Human::Human( int age, const char* name ) {	// Constructor
	this->age = age;
	strcpy( this->name, name );
}

void Human::getinfo( ) {	// Definition
	cout << "name : " << this->name << "\n" << "age :" << this->age << endl;
}


// designer
// ------------------------------------------------------------------
// user


int main( void ) { 
	Human( 99, "machao" ).getinfo( );
	Human h( 22, "zhangfei" );
	h.getinfo( );
	
	Human h2;			// method one
	Human h3( 23, "zhangfei" );	// method two
	Human h4[3];			// method three
	for( int i=0; i<3; i++ ) {
		h4[i].getinfo( );
	}
	Human h5[3] = { Human(22, "zhangei"), Human(23, "guanyu"), Human(25, "zhaoyun") }; // method four
	for( int j=0; j<3; j++ ) {
		h5[j].getinfo( );
	}
	Human h6[] = {			// method five
		Human(22, "zhangei"),
	       	Human(23, "guanyu"),
	       	Human(25, "zhaoyun"),
		Human(55, "huangzhong")
	};
	for( int m=0; m<sizeof(h6)/sizeof(h6[0]); m++ ) {
		h6[m].getinfo( );
	}
	Human* ph = new Human;		// method six
	(*ph).getinfo( );
	delete ph;
	ph = NULL;

	Human* ph2 = new Human( );	// method seven
	(*ph2).getinfo( );
	delete ph2;
	ph2 = NULL;

	Human* ph3 = new Human( 18, "wusong" );// method eight
	(*ph3).getinfo( );
	delete ph3;
	ph3 = NULL;

	Human* ph4 = new Human[3];	// method nine
	for( int i=0; i<3; i++ ) {
		ph4[i].getinfo( );
	}
	delete[] ph4;
	ph4 = NULL;

	Human* ph5 = new Human[3] {	// method ten
		Human( 18, "likui" ),
		Human( 22, "songjiang"),
		Human( 40, "laiqianhui")
	};
	for( int i=0; i<3; i++ ) {
		ph5[i].getinfo( );
	}
	delete[] ph5;
	ph5 = NULL;


	return 0;
}

